package net.qhzw.vip.qiyu.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.qhzw.vip.qiyu.entity.OrderRefunds;
import net.qhzw.vip.qiyu.result.JsonResult;
import net.qhzw.vip.qiyu.service.OrderRefundsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 退款详情
 */
@Slf4j
@RestController
@RequestMapping("/orderrefunds")
@Api(value = "orderrefunds", tags = "退款详情API")
public class OrderRefundsController {

    @Autowired
    private OrderRefundsService orderRefundsService;

    /**
     * 新增退款详情(发起退款) 退款详情
     */
    @ApiOperation(value = "退款申请")
    @PostMapping("/requestRefund")
    public JsonResult requestRefund(@RequestBody OrderRefunds orderRefunds) {
        boolean isOK = orderRefundsService.requestRefund(orderRefunds);
        if (isOK) {
            return JsonResult.ok();
        }
        return JsonResult.fail();
    }


    @ApiOperation(value = "退款审核")
    @PutMapping("/doOrderRefunds")
    public JsonResult doOrderRefunds(@RequestBody OrderRefunds orderRefunds) {
        boolean isOK = orderRefundsService.doOrderRefunds(orderRefunds);
        if (isOK) {
            return JsonResult.ok();
        }
        return JsonResult.fail();
    }


}
